//
//  YLSignRuleView.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/19.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLSignRuleView.h"
#import <Masonry.h>
#import "YLGlobeHeader.h"
@implementation YLSignRuleView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
        self.backgroundColor = YLColorA(30, 30, 30, 0.6);
        self.alpha = 0;
    }
    return self;
}

- (void)setUpUI
{
    
    UIImageView *imageView = [[UIImageView alloc] init];
    [self addSubview:imageView];
    imageView.image = [UIImage imageNamed:@"SignInRulePopupBox"];
    
    __weak typeof(self) weakSelf = self;
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(weakSelf);
        make.left.mas_equalTo(weakSelf).mas_offset(60);
        make.right.mas_equalTo(weakSelf).mas_equalTo(-60);
        make.height.mas_equalTo(imageView.mas_width).multipliedBy(2236 / 1537.0);
    }];
}


- (void)didMoveToSuperview
{
    __weak typeof(self) weakSelf = self;
    [UIView animateWithDuration:0.8 animations:^{
        weakSelf.alpha = 1;
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self removeFromSuperview];
}

@end
